package com.situ.day3;

import java.util.Scanner;

import org.junit.Test;

public class SwitchDemo {

	@Test
	public void test1() {
		int num = 4;
		if (num == 1) {
			System.out.println("1");
		} else if (num == 2) {
			System.out.println("2");
		} else if (num == 3) {
			System.out.println("3");
		} else if (num == 4) {
			System.out.println("4");
		} else {
			System.out.println("其他");
		}
	}

	@Test
	public void test2() {
		int num = 3;
		switch (num) {
		case 1:
			System.out.println("1");
			break;
		case 2:
			System.out.println("2");
			break;
		case 3:
			System.out.println("3");
			break;
		case 4:
			System.out.println("4");
			break;
		default:
			System.out.println("其他");
			break;
		}
	}

	// 输入月份、年份判断天数
	// 1、 3、5、7、8、10、12-------31天
	// 4、6、9、11 --------------------30天
	// 2---------------------------------28/29天
	@Test
	public void test4() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入月份：");
		int month = scanner.nextInt();
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			System.out.println("31");
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			System.out.println("30");
			break;
		case 2:
			System.out.println("请输入年份：");
			int yeay = scanner.nextInt();
			// if (() || ()) {
			//
			// }
			break;
		default:
			break;
		}

	}

	// 计算学生成绩的等级，使用switch
	@Test
	public void test3() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入学生成绩");
		int score = scanner.nextInt();
		switch (score / 10) {// 77 76 78
		case 9:
		case 10:
			System.out.println("优秀");
			break;
		case 8: // [80, 90)
			System.out.println("良好");
			break;
		case 7:
			System.out.println("一般");
			break;
		case 6:
			System.out.println("及格");
			break;
		default:
			System.out.println("不及格");
			break;
		}
	}

}
